{// 引入标签库 }
<tagLib name="fanwe" />
{// 加载头部公共文件 }
<include file="Public:header" />
<load href="__TMPL__ThemeFiles/Js/jquery.js" />
<load href="__TMPL__ThemeFiles/Js/jquery.json.js" />
<!-- 菜单区域  -->

<!-- 主页面开始 -->
<div id="main" class="main" >

<!-- 主体内容  -->
<div class="content" >
<div class="title">{$Think.lang.DATA_LIST}</div>
<!--  功能操作区域  -->
<form method='get' action="__ROOT__/{:fanweC('ADMIN_FILE_NAME')}">
<div class="operate" >
<!-- 查询区域 -->



&nbsp;&nbsp;&nbsp;&nbsp;会员：<input type="text" name="user_name" class="medium" style="width:100px;" value="{:trim($_REQUEST['user_name'])}" >
&nbsp;&nbsp;推荐人：<input type="text" name="parent_name" class="medium" style="width:100px;" value="{:trim($_REQUEST['parent_name'])}" >
<select name="is_pay">
	<option value="-1" <if condition="$map['is_pay'] eq -1">selected="selected"</if>>返利状态</option>
    <option value="0" <if condition="$map['is_pay'] eq 0">selected="selected"</if>>未返利</option>
    <option value="1" <if condition="$map['is_pay'] eq 1">selected="selected"</if>>已返利</option>
</select>

<select name="city_id">
	<option value="0" <if condition="$map['city_id'] eq 0">selected="selected"</if>>全部</option>
	<foreach name="city_list" item="city_item">
		<option value="{$city_item.id}" <if condition="$map['city_id'] eq $city_item['id']">selected="selected"</if>>{$city_item.name}</option>
	</foreach>	
</select>

团购ID：<input type="text" name="goods_id" value="{$map.goods_id}" />
<input type="hidden" name="m" value="Referrals" />
<input type="hidden" name="a" value="index" />
<fanwe:imageBtn type="submit" name="search" value="{$Think.lang._SEARCH_DATA}" style="impBtn hMargin fLeft shadow" />


</div>
<!-- 高级查询区域 -->

</form>

<!-- 功能操作区域结束 -->

<!-- 列表显示区域  -->
<div class="list" >
<fanwe:list 
	id="checkList" 
	name="referrals" 
	style="list" 
	checkbox="true" 
	action="true" 
	datasource="list" 
	child="true" 
	show="id:{$Think.lang.ID}|8%,user_name:会员,parent_name:推荐人,goods_name:团购项目,money|priceFormat:返利金额,score:返利积分,create_time|toDate:返利创建时间,pay_time|toDate:返利发放时间,city_id|getCityName:城市" 
	actionlist="is_pay|A('Referrals')->payStatus=$referrals['id']" /> 
</div>
<!--  分页显示区域 -->
<div class="page">返利金额合计：{$sum.pay_money|formatPrice} 返利积分合计：{$sum.pay_score|intval|formatScore}</div>
<div class="page">{$pages}</div>
<!-- 列表显示区域结束 -->
</div>
<!-- 主体内容结束 -->
</div>
<!-- 主页面结束 -->
<script type="text/javascript">
function referralsPay(id,obj)
{
	$.ajax({
		  url: APP+"?"+VAR_MODULE+"=Referrals&"+VAR_ACTION+"=pay&id="+id,
		  cache: false,
		  success:function(data)
		  {
			  $(obj).parent().append(data);
			  $(obj).remove();
		  }
	});	
	return false;
}

function referralsUnPay(id,obj)
{
	$.ajax({
		  url: APP+"?"+VAR_MODULE+"=Referrals&"+VAR_ACTION+"=unPay&id="+id,
		  cache: false,
		  success:function(data)
		  {
			  $(obj).parent().append(data);
			  $(obj).remove();
		  }
	});	
	return false;
}

function referralsDelete(id,obj)
{
	if(window.confirm(CONFIRM_DELETE))
	{
		$.ajax({
			  url: APP+"?"+VAR_MODULE+"=Referrals&"+VAR_ACTION+"=deleteReferrals&id="+id,
			  cache: false,
			  success:function(data)
			  {
				  if(data == 1)
					{
						if($(".page a").length > 0)
						{
							var url = 	$(".page a:first").attr("href");
							var page =  parseInt($(".page span.current").html());
							var urlArr = url.split("&p=");
							var reurl = urlArr[0] + "&p=" + page;
							location.href = reurl;
						}
						else
						{
							$(obj).parent().parent().parent().remove();
						}
					}
				  else
				  	alert("删除失败");
			  }
		});	
	}
	return false;
}
</script>
